From: Matthieu Gallien Date: Wed, 21 May 2025 08:37:09 +0000 (+0200) Subject: fix(moveToTrash): enable use of move to trash in some automated tests X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1^2~13^2~1^2~37^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=4b710c66b6d1a3effd1dcf5219a8c3547e1ee124;p=nextcloud-desktop.git fix(moveToTrash): enable use of move to trash in some automated tests should improve coverage for move to trash feature to ensure this is working as expected by users Signed-off-by: Matthieu Gallien --- diff --git a/test/testpermissions.cpp b/test/testpermissions.cpp index 38970d8ef..50fc424d4 100644 --- a/test/testpermissions.cpp +++ b/test/testpermissions.cpp @@ -94,9 +94,23 @@ private slots: QStandardPaths::setTestModeEnabled(true); } + void t7pl_data() + { + QTest::addColumn("moveToTrashEnabled"); + QTest::newRow("move to trash") << true; + QTest::newRow("delete") << false; + } + void t7pl() { + QFETCH(bool, moveToTrashEnabled); + FakeFolder fakeFolder{ FileInfo() }; + + auto syncOptions = fakeFolder.syncEngine().syncOptions(); + syncOptions._moveFilesToTrash = moveToTrashEnabled; + fakeFolder.syncEngine().setSyncOptions(syncOptions); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); // Some of this test depends on the order of discovery. With threading diff --git a/test/testsyncengine.cpp b/test/testsyncengine.cpp index 3d7124421..cd10e51bb 100644 --- a/test/testsyncengine.cpp +++ b/test/testsyncengine.cpp @@ -216,8 +216,23 @@ private slots: QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); } + + void testLocalDelete_data() + { + QTest::addColumn("moveToTrashEnabled"); + QTest::newRow("move to trash") << true; + QTest::newRow("delete") << false; + } + void testLocalDelete() { + QFETCH(bool, moveToTrashEnabled); + FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()}; + + auto syncOptions = fakeFolder.syncEngine().syncOptions(); + syncOptions._moveFilesToTrash = moveToTrashEnabled; + fakeFolder.syncEngine().setSyncOptions(syncOptions); + ItemCompletedSpy completeSpy(fakeFolder); fakeFolder.remoteModifier().remove("A/a1"); fakeFolder.syncOnce(); @@ -234,10 +249,23 @@ private slots: QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); } + void testLocalDeleteWithReuploadForNewLocalFiles_data() + { + QTest::addColumn("moveToTrashEnabled"); + QTest::newRow("move to trash") << true; + QTest::newRow("delete") << false; + } + void testLocalDeleteWithReuploadForNewLocalFiles() { + QFETCH(bool, moveToTrashEnabled); + FakeFolder fakeFolder{FileInfo{}}; + auto syncOptions = fakeFolder.syncEngine().syncOptions(); + syncOptions._moveFilesToTrash = moveToTrashEnabled; + fakeFolder.syncEngine().setSyncOptions(syncOptions); + // create folders hierarchy with some nested dirs and files fakeFolder.localModifier().mkdir("A"); fakeFolder.localModifier().insert("A/existingfile_A.txt", 100); @@ -1563,9 +1591,23 @@ private slots: QCOMPARE(fileThirdSync->lastModified.toSecsSinceEpoch(), CURRENT_MTIME); } + void testFolderRemovalWithCaseClash_data() + { + QTest::addColumn("moveToTrashEnabled"); + QTest::newRow("move to trash") << true; + QTest::newRow("delete") << false; + } + void testFolderRemovalWithCaseClash() { - FakeFolder fakeFolder{ FileInfo{} }; + QFETCH(bool, moveToTrashEnabled); + + FakeFolder fakeFolder{FileInfo{}}; + + auto syncOptions = fakeFolder.syncEngine().syncOptions(); + syncOptions._moveFilesToTrash = moveToTrashEnabled; + fakeFolder.syncEngine().setSyncOptions(syncOptions); + fakeFolder.remoteModifier().mkdir("A"); fakeFolder.remoteModifier().mkdir("toDelete"); fakeFolder.remoteModifier().insert("A/file"); @@ -1848,8 +1890,17 @@ private slots: } } + void testServer_caseClash_createConflict_thenRemoveOneRemoteFile_data() + { + QTest::addColumn("moveToTrashEnabled"); + QTest::newRow("move to trash") << true; + QTest::newRow("delete") << false; + } + void testServer_caseClash_createConflict_thenRemoveOneRemoteFile() { + QFETCH(bool, moveToTrashEnabled); + constexpr auto testLowerCaseFile = "test"; constexpr auto testUpperCaseFile = "TEST"; @@ -1861,6 +1912,10 @@ private slots: FakeFolder fakeFolder{FileInfo{}}; + auto syncOptions = fakeFolder.syncEngine().syncOptions(); + syncOptions._moveFilesToTrash = moveToTrashEnabled; + fakeFolder.syncEngine().setSyncOptions(syncOptions); + fakeFolder.remoteModifier().insert("otherFile.txt"); fakeFolder.remoteModifier().insert(testLowerCaseFile); fakeFolder.remoteModifier().insert(testUpperCaseFile);